package com.xyzq.hs;

import java.util.HashMap;
import java.util.Map;

import com.xyzq.hs.util.ByteUtils;

public class ResultSetMetaData{
	
	private Short columnCount;
	
	private String[] columnNames;
	
	private char[] columnTypes;
	
	private Map<String,Short> column;
	
	public ResultSetMetaData(short columnCount, String[] columnNames, char[] columnTypes) {
		super();
		this.columnCount = columnCount;
		this.columnNames = columnNames;
		this.columnTypes = columnTypes;
		column=new HashMap<String, Short>();
		for(int i=0;i<columnNames.length;i++){
			column.put(columnNames[i], Short.valueOf((short)i));
		}
	}

	public short getColumnCount()  {
		return columnCount;
	}
	
	public String getColumnName(int column)  {
		return columnNames[column];
	}
	
	public char getColumnType(int column)  {
		return columnTypes[column];
	}
	

	public String getColumnTypeName(int column)  {
		return ByteUtils.byte2str(ByteUtils.int2byte(columnTypes[column]));
	}

	public Short getColumnIndex(String columnName) {
		return column.get(columnName);
	}
	
	public static void main(String[] args) {
		
	}

}
